USE [dbdata]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Users_treminals_Users_treminals]') AND parent_object_id = OBJECT_ID(N'[dbo].[Users_terminals]'))
ALTER TABLE [dbo].[Users_terminals] DROP CONSTRAINT [FK_Users_treminals_Users_treminals]
GO

USE [dbdata]
GO

/****** Object:  Table [dbo].[Users_terminals]    Script Date: 03/19/2012 22:41:38 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users_terminals]') AND type in (N'U'))
DROP TABLE [dbo].[Users_terminals]
GO

USE [dbdata]
GO

/****** Object:  Table [dbo].[Users_terminals]    Script Date: 03/19/2012 22:41:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Users_terminals](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[Uid] [int] NULL,
	[Terminal_id] [int] NULL,
 CONSTRAINT [PK_Users_treminals] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Users_terminals]  WITH CHECK ADD  CONSTRAINT [FK_Users_treminals_Users_treminals] FOREIGN KEY([Uid])
REFERENCES [dbo].[users] ([id])
GO

ALTER TABLE [dbo].[Users_terminals] CHECK CONSTRAINT [FK_Users_treminals_Users_treminals]
GO

